<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <base target="_self">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache,must-ridate">
    <meta http-equiv="expires" content="0">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/static/plugins/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/plugins/bootstrap-table/bootstrap-table.css" />
    <script type="text/javascript" src="/static/plugins/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="/static/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/plugins/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="/static/plugins/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
</head>

<style  type="text/css">
    .required {
        color: red;
    }
</style>

<body>
    <div style="text-align: left;">
        &nbsp;&nbsp;<button type="button" id="btnAdd" class="btn btn-danger">创 建</button>
    </div>
    <div style="height: 5px;"></div>
    <table id="syqjgList"></table>
</body>
    
    <script type="text/javascript">
        //初始化数据
        let ydjData = new Object();
        $(function () {
            let uuid = GetQueryValue('uuid');
            let bsid = GetQueryValue('bsid');
            let regitem_id = GetQueryValue('regitem_id');
            let productid = GetQueryValue('productid');
            let productcode = GetQueryValue('productcode');
            
            //加载受益权结构
            loadSyqjg(uuid);

            //新增受益权结构
            $("#btnAdd").click(function(){
                $(window.parent.$('#syqjgIFrame')).attr('src', "/node/syqjgInfo.html" + '?id=0' + '&uuid=' + uuid + '&bsid=' + bsid + '&regitem_id=' + regitem_id + '&productid=' + productid + '&productcode=' + productcode);
            });
        });
        
        //加载受益权结构
        function loadSyqjg(uuid) {
            $("#syqjgList").bootstrapTable({
                method: "post",
                url:"/node/find_app_dfs_zxd_cssyq_by_uuid",   //请求地址
                striped : true, //是否显示行间隔色
                pageNumber : 1, //初始化加载第一页
                pagination : true,//是否分页
                sidePagination : 'server',//server:服务器端分页|client：前端分页
                pageSize : 10,//单页记录数
                pageList : [10],//可选择单页记录数
                queryParams : function(params) {//上传服务器的参数
                    var temp = {
                        uuid: uuid,
                        offset :params.offset + 0,// SQL语句起始索引
                        pageNumber : params.limit  // 每页显示数量
                    };
                    return temp;
                },columns: [{
                    field: 'syqxh',
                    title: '受益权序号'
                }, {
                    field: 'syqdm',
                    title: '受益权代码'
                }, {
                    field: 'syqlx',
                    title: '受益权类型'
                }, {
                    field: 'fpsx',
                    title: '分配顺序'
                }, {
                    field: 'syqsyllx',
                    title: '受益权收益率类型'
                }, {
                    field: 'syqyqsyl',
                    title: '受益权收益率'
                }, {
                    field: 'fhfs',
                    title: '分红方式'
                }, {
                    field: 'fpfs',
                    title: '分配方式'
                }, {
                    field: 'fppl',
                    title: '分配频率'
                }, {
                    title: '操作',
                    align: 'center',
                    width: 80,
                    formatter:function(value,row,index){
                        return `<a href="javascript:updateSyqjg('`+row.id+`', '`+uuid+`','`+row.bsid+`','`+row.regitem_id+`','`+row.productid+`','`+row.productcode+`')">编辑</a> `
                              +`<a href="javascript:deleteSyqjg('`+row.id+`', '`+uuid+`')">删除</a> `;
                    }
                }]
            });
        }

        //编辑受益权结构
        function updateSyqjg(id, uuid, bsid, regitem_id, productid, productcode) {
            $(window.parent.$('#syqjgIFrame')).attr('src', "/node/syqjgInfo.html" + '?id=' + id + '&uuid=' + uuid + '&bsid=' + bsid + '&regitem_id=' + regitem_id + '&productid=' + productid + '&productcode=' + productcode);
        }

        //删除受益权结构
        function deleteSyqjg(id, uuid) {
			if (confirm("确定执行受益权结构删除操作吗？"))
			{		
				let tjdNos = new Object();
				tjdNos.id = id;
				jQuery.ajax({
					//请求方式
					type: "POST",
					//请求地址
					url: "/node/delete_app_dfs_zxd_cssyq",
					//数据，json对象
					data: tjdNos,
					//请求成功
					success: function (data) {
						if (data.code == "1") {
							alert("受益权结构删除成功！");
							$('#syqjgList').bootstrapTable('refresh');
						} else if (data.code == "3") {
							alert("受益权结构ID为空！");
						} else {
							alert("受益权结构删除失败！");
						}
					},
					//请求失败，包含具体的错误信息
					error: function (e) {
						alert("数据请求异常！");
					}
				});
			}
        }

        //获取GET参数
        function GetQueryValue(queryName) {
            var query = decodeURI(window.location.search.substring(1));
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == queryName) { return pair[1]; }
            }
            return null;
        }
    </script>
</html>